#pragma once
#include <sys/types.h>
#include <sys/socket.h>
#include <cerrno>
#include "Log.hpp"


enum 
{
    SOCKET_ERROR = 1,
    BIND_ERROR,
    USAGE_ERROR,
    LISTEN_ERROR,
    ACCEPT_ERROR,
    READ_ERROR,
    WRITE_ERROR
};

#define CONV(socket) ((struct sockaddr*)socket)

void WriteErrorMethod(int n)
{
    if (n < 0)
    {
        lg.LogMessage(Error, "write error, errno %d is %s", errno, strerror(errno));
        exit(WRITE_ERROR);
    }
    else if (n == 0)
    {
        lg.LogMessage(Info, "server quit\n");
    }
}